#include "qimagechoosedialog.h"
#include "ui_qimagechoosedialog.h"

#include "qresourcetreewidget.h"

using namespace CORELIB;

QImageChooseDialog::QImageChooseDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::QImageChooseDialog),
    m_imageList(new QResourceTreeWidget)
{
    ui->setupUi(this);

    ui->verticalLayout->insertWidget(0,m_imageList,1);

    connect(m_imageList,SIGNAL(doubleClick(QString,QString)),this,SLOT(doubleSelect(QString,QString)));
}

QImageChooseDialog::~QImageChooseDialog()
{
    delete ui;
}

void CORELIB::QImageChooseDialog::on_okBtn_clicked()
{
    m_imageList->getSelectResource(m_firstName,m_lastName);
    if(m_firstName!="" && m_lastName!="")
    {
        close();
    }
}

void CORELIB::QImageChooseDialog::on_cancelBtn_clicked()
{
    close();
}

void QImageChooseDialog::doubleSelect(const QString &firstName, const QString &lastName)
{
    m_firstName=firstName;
    m_lastName=lastName;
    if(m_firstName!="" && m_lastName!="")
    {
        close();
    }
}

void QImageChooseDialog::getImage(QString &firstName, QString &lastName)
{
    firstName=m_firstName;
    lastName=m_lastName;
}
